import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getPeriodTree } from '/@/api/common/api';
import dayjs from 'dayjs';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '主键',
    align: 'center',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '班组编码',
    align: 'center',
    dataIndex: 'orgCode',
    ifShow: false,
  },
  {
    title: '班组名称',
    align: 'center',
    dataIndex: 'orgName',
    width: 160,
  },
  {
    title: '人员类型',
    align: 'center',
    dataIndex: 'personType',
    width: 160,
    customRender: ({ text }) => {
      return render.renderDict(text, 'hub_person_type2');
    },
  },
  {
    title: '考核周期',
    align: 'center',
    dataIndex: 'periodCode',
    width: 160,
    // customRender: ({ text }) => {
    //   return text.slice(0, 4) + '年' + text.slice(4) + '月';
    // },
  },
  {
    title: '员工姓名',
    align: 'center',
    dataIndex: 'psnName',
    width: 160,
  },
  {
    title: '综合得分',
    align: 'center',
    dataIndex: 'finalScore',
    width: 160,
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'status',
    width: 160,
    ifShow: false,
  },
];

export const columns1: BasicColumn[] = [
  {
    title: '主键',
    align: 'center',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '指标',
    align: 'center',
    dataIndex: 'indexName',
    width: 160,
  },
  {
    title: '权重（%）',
    align: 'center',
    dataIndex: 'factorWeight',
    width: 160,
  },
];

// const currentMoth = () => {
//   const year = new Date().getFullYear();
//   let month = new Date().getMonth() + 1;
//   if (10 > month) {
//     // @ts-ignore
//     month = '0' + month;
//   }
//   return year + month;
// };
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'periodCode',
    label: '考核周期',
    component: 'Select',
    colProps: { span: 6 },
    defaultValue: dayjs().format('YYYYMM'),
  },
  {
    field: 'orgCode',
    component: 'Select',
    label: '班组1',
    componentProps: {
      options: userStore.getTeamList,
    },
    defaultValue: userStore.getOrgCode,
    colProps: { span: 6, },
  },
  {
    field: 'psnName',
    label: '员工姓名',
    component: 'Input',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '主键',
    field: 'id',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入主键!' }];
    },
  },
  {
    label: '考核周期',
    field: 'periodCode',
    component: 'Input',
  },
  {
    label: '组织编码',
    field: 'orgCode',
    component: 'Input',
  },
  {
    label: '组织名称',
    field: 'orgName',
    component: 'Input',
  },
  {
    label: '姓名',
    field: 'psnName',
    component: 'Input',
  },
  {
    label: '工号',
    field: 'psnNum',
    component: 'Input',
  },
  {
    label: '人员类型',
    field: 'personType',
    component: 'Input',
  },
  {
    label: '岗位编码',
    field: 'posCode',
    component: 'Input',
  },
  {
    label: '岗位名称',
    field: 'posName',
    component: 'Input',
  },
  {
    label: '模板配置1',
    field: 'elementScore1',
    component: 'Input',
  },
  {
    label: '模板配置2',
    field: 'elementScore2',
    component: 'Input',
  },
  {
    label: '模板配置3',
    field: 'elementScore3',
    component: 'Input',
  },
  {
    label: '模板配置4',
    field: 'elementScore4',
    component: 'Input',
  },
  {
    label: '模板配置5',
    field: 'elementScore5',
    component: 'Input',
  },
  {
    label: '模板配置6',
    field: 'elementScore6',
    component: 'Input',
  },
  {
    label: '模板配置7',
    field: 'elementScore7',
    component: 'Input',
  },
  {
    label: '模板配置8',
    field: 'elementScore8',
    component: 'Input',
  },
  {
    label: '模板配置9',
    field: 'elementScore9',
    component: 'Input',
  },
  {
    label: '模板配置10',
    field: 'elementScore10',
    component: 'Input',
  },
  {
    label: '权重1',
    field: 'weight1',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重1!' }];
    },
  },
  {
    label: '权重2',
    field: 'weight2',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重2!' }];
    },
  },
  {
    label: '权重3',
    field: 'weight3',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重3!' }];
    },
  },
  {
    label: '权重4',
    field: 'weight4',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重4!' }];
    },
  },
  {
    label: '权重5',
    field: 'weight5',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重5!' }];
    },
  },
  {
    label: '权重6',
    field: 'weight6',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重6!' }];
    },
  },
  {
    label: '权重7',
    field: 'weight7',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重7!' }];
    },
  },
  {
    label: '权重8',
    field: 'weight8',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重8!' }];
    },
  },
  {
    label: '权重9',
    field: 'weight9',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重9!' }];
    },
  },
  {
    label: '权重10',
    field: 'weight10',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入权重10!' }];
    },
  },
  {
    label: '评分1',
    field: 'score1',
    component: 'InputNumber',
  },
  {
    label: '评分2',
    field: 'score2',
    component: 'InputNumber',
  },
  {
    label: '评分3',
    field: 'score3',
    component: 'InputNumber',
  },
  {
    label: '评分4',
    field: 'score4',
    component: 'InputNumber',
  },
  {
    label: '评分5',
    field: 'score5',
    component: 'InputNumber',
  },
  {
    label: '评分6',
    field: 'score6',
    component: 'InputNumber',
  },
  {
    label: '评分7',
    field: 'score7',
    component: 'InputNumber',
  },
  {
    label: '评分8',
    field: 'score8',
    component: 'InputNumber',
  },
  {
    label: '评分9',
    field: 'score9',
    component: 'InputNumber',
  },
  {
    label: '评分10',
    field: 'score10',
    component: 'InputNumber',
  },
  {
    label: '评分说明1',
    field: 'scoreDesc1',
    component: 'InputTextArea',
  },
  {
    label: '评分说明2',
    field: 'scoreDesc2',
    component: 'InputTextArea',
  },
  {
    label: '评分说明3',
    field: 'scoreDesc3',
    component: 'InputTextArea',
  },
  {
    label: '评分说明4',
    field: 'scoreDesc4',
    component: 'InputTextArea',
  },
  {
    label: '评分说明5',
    field: 'scoreDesc5',
    component: 'InputTextArea',
  },
  {
    label: '评分说明6',
    field: 'scoreDesc6',
    component: 'InputTextArea',
  },
  {
    label: '评分说明7',
    field: 'scoreDesc7',
    component: 'InputTextArea',
  },
  {
    label: '评分说明8',
    field: 'scoreDesc8',
    component: 'InputTextArea',
  },
  {
    label: '评分说明9',
    field: 'scoreDesc9',
    component: 'InputTextArea',
  },
  {
    label: '评分说明10',
    field: 'scoreDesc10',
    component: 'InputTextArea',
  },
  {
    label: '考核得分',
    field: 'finalScore',
    component: 'InputNumber',
  },
  {
    label: '状态',
    field: 'status',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入状态!' }];
    },
  },
  {
    label: '适用单位',
    field: 'suitUnit',
    component: 'Input',
  },
  {
    label: '显示排序',
    field: 'displayOrder',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入显示排序!' }];
    },
  },
  {
    label: '创建日期',
    field: 'sysCreateDate',
    component: 'DatePicker',
  },
  {
    label: '创建人',
    field: 'sysCreatorId',
    component: 'Input',
  },
  {
    label: '修改日期',
    field: 'sysUpdateDate',
    component: 'DatePicker',
  },
  {
    label: '修改人',
    field: 'sysUpdatorId',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
